﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MessageShark;
using Phoenix.ZeroMQConnectors;
using PServiceBus.Gateway.Interfaces.Commands;
using PServiceBus.Gateway.ZeroMQ.Commands;
using PServiceBus.Gateway.ZeroMQ.DTO;

namespace PServiceBus.Gateway.ZeroMQ {
    internal class ZeroMQSerializationBootstrapper {
        public static void Configure() {

            if (!MessageSharkSerializer.IsTypeRegisterFor<MessageBase>(typeof(ZeroMQBusMessage)))
                MessageSharkSerializer.RegisterTypeFor<MessageBase>(typeof(ZeroMQBusMessage), 3);
            if (!MessageSharkSerializer.IsTypeRegisterFor<MessageBase>(typeof(ZeroMQRouterMessage)))
                MessageSharkSerializer.RegisterTypeFor<MessageBase>(typeof(ZeroMQRouterMessage), 4);


            if (!MessageSharkSerializer.IsTypeRegisterFor<BusMessage>(typeof(ZeroMQBusMessage)))
                MessageSharkSerializer.RegisterTypeFor<BusMessage>(typeof(ZeroMQBusMessage), 1);
            if (!MessageSharkSerializer.IsTypeRegisterFor<RouterMessage>(typeof(ZeroMQRouterMessage)))
                MessageSharkSerializer.RegisterTypeFor<RouterMessage>(typeof(ZeroMQRouterMessage), 2);

            if (!MessageSharkSerializer.IsTypeRegisterFor<IZeroMQCommand>(typeof(ZeroMQBusMessage)))
                MessageSharkSerializer.RegisterTypeFor<IZeroMQCommand>(typeof(ZeroMQBusMessage), 1);
            if (!MessageSharkSerializer.IsTypeRegisterFor<IZeroMQCommand>(typeof(ZeroMQRouterMessage)))
                MessageSharkSerializer.RegisterTypeFor<IZeroMQCommand>(typeof(ZeroMQRouterMessage), 2);

            if (!MessageSharkSerializer.IsTypeRegisterFor<IZeroMQCommand>(typeof(ZeroMQESBRequest)))
                MessageSharkSerializer.RegisterTypeFor<IZeroMQCommand>(typeof(ZeroMQESBRequest), 3);
            if (!MessageSharkSerializer.IsTypeRegisterFor<IZeroMQCommand>(typeof(ZeroMQRouterRequest)))
                MessageSharkSerializer.RegisterTypeFor<IZeroMQCommand>(typeof(ZeroMQRouterRequest), 4);

            if (!MessageSharkSerializer.IsTypeRegisterFor<IZeroMQCommandReply>(typeof(ZeroMQServiceInfos)))
                MessageSharkSerializer.RegisterTypeFor<IZeroMQCommandReply>(typeof(ZeroMQServiceInfos), 1);
            if (!MessageSharkSerializer.IsTypeRegisterFor<IZeroMQCommandReply>(typeof(ZeroMQSubscriberInfo)))
                MessageSharkSerializer.RegisterTypeFor<IZeroMQCommandReply>(typeof(ZeroMQSubscriberInfo), 2);
            if (!MessageSharkSerializer.IsTypeRegisterFor<IZeroMQCommandReply>(typeof(ZeroMQTopicInfos)))
                MessageSharkSerializer.RegisterTypeFor<IZeroMQCommandReply>(typeof(ZeroMQTopicInfos), 3);
            if (!MessageSharkSerializer.IsTypeRegisterFor<IZeroMQCommandReply>(typeof(ZeroMQESBTopicInfo)))
                MessageSharkSerializer.RegisterTypeFor<IZeroMQCommandReply>(typeof(ZeroMQESBTopicInfo), 4);
        }
    }
}
